<article class="" id="post-">
<header class="entry-header">
<h1 class="entry-title">jQuery.isNumeric()</h1>
<div class="entry-meta">
						所属分类：<span class="category"><a href="/category/utilities/">工具类</a></span>
<span class="pull-right">英文文档：<a href="https://api.jquery123.com/jQuery.isNumeric/" target="_blank">jQuery.isNumeric()</a></span>
</div><!-- .entry-meta -->
</header><!-- .entry-header -->
<!-- .entry-header -->
<div class="entry-content">
<article class="entry method" id="jQuery-isNumeric1"><h2 class="section-title">
<span class="name">jQuery.isNumeric( value )</span><span class="returns">返回: <a href="/Types/#Boolean">Boolean</a></span>
</h2>
<div class="entry-wrapper">
<p class="desc"><strong>描述: </strong>确定它的参数是否是一个数字。</p>
<ul class="signatures"><li class="signature" id="jQuery-isNumeric-value">
<h4 class="name">
<span class="version-details">添加的版本: <a href="/category/version/1.7/">1.7</a></span>jQuery.isNumeric( value )</h4>
<ul><li>
<div><strong>value</strong></div>
<div>类型: <a href="/Types/#PlainObject">PlainObject</a>
</div>
<div>用于测试的值。</div>
</li></ul>
</li></ul>
<div class="longdesc" id="entry-longdesc">
<p>
<code>$.isNumeric()</code> 方法检查它的参数是否代表一个数值。如果是，它返回 <code>true</code>。否则，它返回<code>false</code>。该参数可以是任何类型。
			</p>
</div>
<section class="entry-examples" id="entry-examples"><header><h2 class="underline">例子:</h2></header><div class="entry-example" id="example-0">
<h4><span class="desc">以下是使用 $.isNumeric 检测各种输入类型的例子。</span></h4>
<div class="syntaxhighlighter javascript ">
<table>
<tbody>
<tr>
<td class="gutter">
<div class="line n1">1</div>
<div class="line n2">2</div>
<div class="line n3">3</div>
<div class="line n4">4</div>
<div class="line n5">5</div>
<div class="line n6">6</div>
<div class="line n7">7</div>
<div class="line n8">8</div>
<div class="line n9">9</div>
<div class="line n10">10</div>
<div class="line n11">11</div>
<div class="line n12">12</div>
<div class="line n13">13</div>
<div class="line n14">14</div>
<div class="line n15">15</div>
</td>
<td class="code">
<pre><div class="container"><div class="line"><code>$.isNumeric(<span class="string">"-10"</span>);  <span class="comment">// true</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="number">16</span>);     <span class="comment">// true</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="number">0xFF</span>);   <span class="comment">// true</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="string">"0xFF"</span>); <span class="comment">// true</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="string">"8e5"</span>);  <span class="comment">// true (exponential notation string)</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="number">3.1415</span>); <span class="comment">// true</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(+<span class="number">10</span>);    <span class="comment">// true</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="number">0144</span>);   <span class="comment">// true (octal integer literal)</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="string">""</span>);     <span class="comment">// false</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric({});     <span class="comment">// false (empty object)</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="literal">NaN</span>);    <span class="comment">// false</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="literal">null</span>);   <span class="comment">// false</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="literal">true</span>);   <span class="comment">// false</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="literal">Infinity</span>); <span class="comment">// false</span></code></div></div><div class="container"><div class="line"><code>$.isNumeric(<span class="literal">undefined</span>); <span class="comment">// false</span></code></div></div></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div></section>
</div></article> </div>
</article>